package com.ljfiction.book.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.bumptech.glide.Glide;
import com.ljfiction.book.Baner.BookdatasBean;
import com.ljfiction.book.MyView.CircularImageView;
import com.ljfiction.book.R;
import com.ljfiction.book.tools.ScreenUtils;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/7/12.
 */

public class FensiAdapter_bookDatals extends BaseAdapter {
    private List<BookdatasBean.DataBean.FansInfoListBean.ListBean> listuser=new ArrayList<>();
    private Context context;

    public FensiAdapter_bookDatals(List<BookdatasBean.DataBean.FansInfoListBean.ListBean> listuser,Context context) {
        this.context = context;
        this.listuser=listuser;

    }

    @Override
    public int getCount() {

        if (listuser.size()>=5){
            return 5;
        }else {
            return listuser.size();
        }
        }


    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        UsersFensi usersFensi = null;
        if (convertView == null) {
            usersFensi = new UsersFensi();
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.fensi_bookdatas, null);
            usersFensi.imageView= (CircularImageView) convertView.findViewById(R.id.yuanfensiImage);
            convertView.setTag(usersFensi);
            AutoUtils.autoSize(convertView);
        } else {
            usersFensi = (UsersFensi)convertView.getTag();
        }
        Glide.with(context).load(listuser.get(position).getUserHeadPortraitURL()).override(ScreenUtils.getNum(parent.getContext(),40),ScreenUtils.getNum(parent.getContext(),40)).into(usersFensi.imageView);
        return convertView;
    }

    public class UsersFensi {

        private CircularImageView imageView;
    }
}
